//////////////////////////////////
///生成时间:2012-03-05 15:01:44
///BaseModel:Cms分类(Cms_Type)(Cms_Type)
//////////////////////////////////
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace yule.Model.Base.Cms
{
    /// <summary>
    /// Cms分类(Cms_Type) (Cms_Type)
    /// </summary>
    [DataContract]
    [Serializable]
    public abstract class Type : yule.Model.IModel<yule.Model.Cms.Type>
    {
        #region 属性

        /// <summary>
        /// 主键
        /// </summary>
        private dynamic _Id = null;
        /// <summary>
        /// 主键 char(32)
        /// </summary>
        [DataMember]
        public dynamic Id
        {
            get { return this._Id; }
            set { this._Id = value; }
        }

        /// <summary>
        /// 所属地区
        /// </summary>
        private string _ParentId = null;
        /// <summary>
        /// 所属地区 char(32)
        /// </summary>
        [DataMember]
        public string ParentId
        {
            get { return this._ParentId; }
            set { this._ParentId = value; }
        }

        /// <summary>
        /// 路径ID
        /// </summary>
        private string _PathId = null;
        /// <summary>
        /// 路径ID nvarchar(20)
        /// </summary>
        [DataMember]
        public string PathId
        {
            get { return this._PathId; }
            set { this._PathId = value; }
        }

        /// <summary>
        /// 名称
        /// </summary>
        private string _Name = null;
        /// <summary>
        /// 名称 nvarchar(50)
        /// </summary>
        [DataMember]
        public string Name
        {
            get { return this._Name; }
            set { this._Name = value; }
        }

        /// <summary>
        /// 路径名称
        /// </summary>
        private string _ParentName = null;
        /// <summary>
        /// 路径名称 nvarchar(200)
        /// </summary>
        [DataMember]
        public string ParentName
        {
            get { return this._ParentName; }
            set { this._ParentName = value; }
        }

        /// <summary>
        /// 编码
        /// </summary>
        private string _Code = null;
        /// <summary>
        /// 编码 nvarchar(50)
        /// </summary>
        [DataMember]
        public string Code
        {
            get { return this._Code; }
            set { this._Code = value; }
        }

        /// <summary>
        /// 排序号
        /// </summary>
        private int _Sort = int.MinValue;
        /// <summary>
        /// 排序号 int
        /// </summary>
        [DataMember]
        public int Sort
        {
            get { return this._Sort; }
            set { this._Sort = value; }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 转化实体
        /// </summary>
        public void Convert(System.Data.DataRow row)
        {
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.Id) == true)
            {
                this.Id = yule.Util.Convert.ToString(row[yule.Model.Cms.Type.Field.Id]);
            }
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.ParentId) == true)
            {
                this.ParentId = yule.Util.Convert.ToString(row[yule.Model.Cms.Type.Field.ParentId]);
            }
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.PathId) == true)
            {
                this.PathId = yule.Util.Convert.ToString(row[yule.Model.Cms.Type.Field.PathId]);
            }
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.Name) == true)
            {
                this.Name = yule.Util.Convert.ToString(row[yule.Model.Cms.Type.Field.Name]);
            }
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.ParentName) == true)
            {
                this.ParentName = yule.Util.Convert.ToString(row[yule.Model.Cms.Type.Field.ParentName]);
            }
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.Code) == true)
            {
                this.Code = yule.Util.Convert.ToString(row[yule.Model.Cms.Type.Field.Code]);
            }
            if (row.Table.Columns.Contains(yule.Model.Cms.Type.Field.Sort) == true)
            {
                this.Sort = yule.Util.Convert.ToInt(row[yule.Model.Cms.Type.Field.Sort]);
            }
        }

        public static yule.Model.Cms.Type Select(dynamic id)
        {
            yule.Model.Cms.Type model = yule.Common.CacheManager.Cache.Get<yule.Model.Cms.Type>(id);

            if (model == null)
            {
                model = yule.Common.ServiceManager.ServiceContext.CreateService<yule.IDAL.Cms.IType>().Select(id);
            }
            return model;
        }

        #endregion

        #region 表

        /// <summary>
        /// 表
        /// </summary>
        public struct Table
        {
            /// <summary>
            /// 表名
            /// </summary>
            public const string Name = "Cms_Type";
        }

        #endregion

        #region 字段

        /// <summary>
        /// 字段
        /// </summary>
        public struct Field
        {
            /// <summary>
            /// 主键
            /// </summary>
            public const string Id = "Id";
            /// <summary>
            /// 所属地区
            /// </summary>
            public const string ParentId = "ParentId";
            /// <summary>
            /// 路径ID
            /// </summary>
            public const string PathId = "PathId";
            /// <summary>
            /// 名称
            /// </summary>
            public const string Name = "Name";
            /// <summary>
            /// 路径名称
            /// </summary>
            public const string ParentName = "ParentName";
            /// <summary>
            /// 编码
            /// </summary>
            public const string Code = "Code";
            /// <summary>
            /// 排序号
            /// </summary>
            public const string Sort = "Sort";
        }

        #endregion

        #region 属性

        /// <summary>
        /// 属性
        /// </summary>
        public struct Property
        {
            /// <summary>
            /// 主键
            /// </summary>
            public const string Id = "Id";
            /// <summary>
            /// 所属地区
            /// </summary>
            public const string ParentId = "ParentId";
            /// <summary>
            /// 路径ID
            /// </summary>
            public const string PathId = "PathId";
            /// <summary>
            /// 名称
            /// </summary>
            public const string Name = "Name";
            /// <summary>
            /// 路径名称
            /// </summary>
            public const string ParentName = "ParentName";
            /// <summary>
            /// 编码
            /// </summary>
            public const string Code = "Code";
            /// <summary>
            /// 排序号
            /// </summary>
            public const string Sort = "Sort";
        }

        #endregion

    }
}